#pragma	once

#include "ZSingleton.h"
#include "ZCommon.h"
#include <boost/pool/pool.hpp>
#include <boost/array.hpp>
#include <boost/shared_ptr.hpp>

namespace	Z	{

//------------------------------------------------------------------------------------------------------------------------
class	_ZMainApi	PoolAllocator
	:	public Singleton<PoolAllocator>
{
public:
	PoolAllocator();
	~PoolAllocator();
	void*	allocate(size_t kSize);
	void	deallocate(void* memory, size_t kSize);
private:
	static	const	size_t	MAX_SMALL_OBJECT_SIZE	= 256;
	typedef	boost::shared_ptr<boost::pool<> >	PoolPtr;
	typedef	boost::array<PoolPtr, MAX_SMALL_OBJECT_SIZE>	PoolPtrArray;
	PoolPtrArray	mPools;
	mutex_t	mLock;
};

}